<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Comment extends CI_Model {

	function __construct() {
		parent::__construct();
	}

	function insert() {

		$comment['comment_post_id'] = $this->input->post('comment_post_id');
		$comment['comment_author'] = $this->input->post('comment_author');
		$comment['comment_author_email'] = $this->input->post('comment_author_email');
		$comment['comment_author_url'] = $this->input->post('comment_author_url');
		$comment['comment_content'] = $this->input->post('comment_content');
		$comment['comment_date'] = date("Y-m-d H:i:s");
		$comment['comment_author_ip'] = ip2long($this->input->ip_address());

		$this->db->insert('comments', $comment);

		return $this->db->affected_rows();
	}
	function get_comments($pid) {
		$this->db->start_cache();
		$this->db->where('comment_post_id', $pid);
		$this->db->select('comment_id,comment_author,comment_author_url,comment_date,user_id,comment_content,comment_parent');
		$this->db->flush_cache();
		return $this->db->get('comments')->result();
	}
}

/* End of file comment.php */
/* Location: ./application/models/comment.php */